#include "gtkcontainerprivate.h"
#include "gtkcsscustomgadgetprivate.h"
#include "gtkcssnodeprivate.h"
+#include "gtkcsspositionvalueprivate.h"
#include "gtkintl.h"
#include "gtkorientable.h"
#include "gtkorientableprivate.h"
#include "gtkprivate.h"
#include "gtktypebuiltins.h"
#include "gtksizerequest.h"
+#include "gtkstylecontextprivate.h"
#include "gtkwidgetpath.h"
#include "gtkwidgetprivate.h"
#include "a11y/gtkcontaineraccessible.h"
}
}
+static gint
+get_spacing (GtkBox *box)
+{
+ GtkBoxPrivate *priv = box->priv;
+ GtkCssValue *border_spacing;
+ gint css_spacing;
+
+ border_spacing = _gtk_style_context_peek_property (gtk_widget_get_style_context (GTK_WIDGET (box)), GTK_CSS_PROPERTY_BORDER_SPACING);
+ if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
+ css_spacing = _gtk_css_position_value_get_x (border_spacing, 100);
+ else
+ css_spacing = _gtk_css_position_value_get_y (border_spacing, 100);
+
+ return css_spacing + priv->spacing;
+}
+
static void
gtk_box_size_allocate_no_center (GtkWidget *widget,
const GtkAllocation *allocation)
gint n_extra_widgets = 0; /* Number of widgets that receive 1 extra px */
gint x = 0, y = 0, i;
gint child_size;
+ gint spacing;
count_expand_children (box, &nvis_children, &nexpand_children);
direction = gtk_widget_get_direction (widget);
sizes = g_newa (GtkRequestedSize, nvis_children);
+ spacing = get_spacing (box);
if (private->orientation == GTK_ORIENTATION_HORIZONTAL)
- size = allocation->width - (nvis_children - 1) * private->spacing;
+ size = allocation->width - (nvis_children - 1) * spacing;
else
- size = allocation->height - (nvis_children - 1) * private->spacing;
+ size = allocation->height - (nvis_children - 1) * spacing;
have_baseline = FALSE;
minimum_above = natural_above = 0;
* minimum sizes for children that are not going to fill
*/
if (private->orientation == GTK_ORIENTATION_HORIZONTAL)
- size = allocation->width - (nvis_children - 1) * private->spacing;
+ size = allocation->width - (nvis_children - 1) * get_spacing (box);
else
- size = allocation->height - (nvis_children - 1) * private->spacing;
+ size = allocation->height - (nvis_children - 1) * get_spacing (box);
extra = size / nvis_children;
n_extra_widgets = size % nvis_children;
if (packing == GTK_PACK_START)
{
- x += child_size + private->spacing;
+ x += child_size + spacing;
}
else
{
- x -= child_size + private->spacing;
+ x -= child_size + spacing;
child_allocation.x -= child_size;
}
if (packing == GTK_PACK_START)
{
- y += child_size + private->spacing;
+ y += child_size + spacing;
}
else
{
- y -= child_size + private->spacing;
+ y -= child_size + spacing;
child_allocation.y -= child_size;
}
gint n_extra_widgets[2];
gint x = 0, y = 0, i;
gint child_size;
+ gint spacing;
nvis[0] = nvis[1] = 0;
nexp[0] = nexp[1] = 0;
sizes[0] = g_newa (GtkRequestedSize, nvis[0]);
sizes[1] = g_newa (GtkRequestedSize, nvis[1]);
+ spacing = get_spacing (box);
if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
box_size = allocation->width;
else
minimum_above = natural_above = 0;
minimum_below = natural_below = 0;
- min_size[0] = nat_size[0] = nvis[0] * priv->spacing;
- min_size[1] = nat_size[1] = nvis[1] * priv->spacing;
+ min_size[0] = nat_size[0] = nvis[0] * spacing;
+ min_size[1] = nat_size[1] = nvis[1] * spacing;
/* Retrieve desired size for visible children. */
idx[0] = idx[1] = 0;
if (priv->homogeneous)
{
- extra[0] = ((box_size - center_size) / 2 - nvis[0] * priv->spacing) / nvis[0];
- extra[1] = ((box_size - center_size) / 2 - nvis[1] * priv->spacing) / nvis[1];
+ extra[0] = ((box_size - center_size) / 2 - nvis[0] * spacing) / nvis[0];
+ extra[1] = ((box_size - center_size) / 2 - nvis[1] * spacing) / nvis[1];
extra[0] = MIN (extra[0], extra[1]);
n_extra_widgets[0] = 0;
}
if ((packing == GTK_PACK_START && direction == GTK_TEXT_DIR_LTR) ||
(packing == GTK_PACK_END && direction == GTK_TEXT_DIR_RTL))
{
- x += child_size + priv->spacing;
+ x += child_size + spacing;
}
else
{
- x -= child_size + priv->spacing;
+ x -= child_size + spacing;
child_allocation.x -= child_size;
}
}
if (packing == GTK_PACK_START)
{
- y += child_size + priv->spacing;
+ y += child_size + spacing;
}
else
{
- y -= child_size + priv->spacing;
+ y -= child_size + spacing;
child_allocation.y -= child_size;
}
}
if (nvis_children > 0 && private->orientation == orientation)
{
+ gint spacing = get_spacing (box);
+
if (private->homogeneous)
{
if (center_min > 0)
natural *= nvis_children;
}
}
- minimum += (nvis_children - 1) * private->spacing;
- natural += (nvis_children - 1) * private->spacing;
+ minimum += (nvis_children - 1) * spacing;
+ natural += (nvis_children - 1) * spacing;
}
minimum = MAX (minimum, minimum_below + minimum_above);
gint child_size, child_minimum, child_natural;
gint child_minimum_baseline, child_natural_baseline;
gint n_extra_widgets = 0;
+ gint spacing;
gboolean have_baseline;
count_expand_children (box, &nvis_children, &nexpand_children);
if (nvis_children <= 0)
return;
+ spacing = get_spacing (box);
sizes = g_newa (GtkRequestedSize, nvis_children);
- size = avail_size - (nvis_children - 1) * private->spacing;
+ size = avail_size - (nvis_children - 1) * spacing;
/* Retrieve desired size for visible children */
for (i = 0, children = private->children; children; children = children->next)
/* If were homogenous we still need to run the above loop to get the
* minimum sizes for children that are not going to fill
*/
- size = avail_size - (nvis_children - 1) * private->spacing;
+ size = avail_size - (nvis_children - 1) * spacing;
extra = size / nvis_children;
n_extra_widgets = size % nvis_children;
}
gint nvis_children = 0;
gint required_size = 0, required_natural = 0, child_size, child_natural;
gint largest_child = 0, largest_natural = 0;
+ gint spacing = get_spacing (box);
for (children = private->children; children != NULL;
children = children->next)
required_natural = largest_natural * nvis_children;
}
- required_size += (nvis_children - 1) * private->spacing;
- required_natural += (nvis_children - 1) * private->spacing;
+ required_size += (nvis_children - 1) * spacing;
+ required_natural += (nvis_children - 1) * spacing;
}
if (minimum_size)